package com.xxxx.dao;

import com.xxxx.pojo.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created By ShaoXikai on 2022/7/22
 */
public interface BookDao {

    // @Insert("insert into tbl_book values(null,#{type},#{name},#{description})")
    @Insert("insert into ssm_db.tbl_book (type,name,description) values(#{type},#{name},#{description})")
    int save(Book book);

    @Update("update ssm_db.tbl_book set type = #{type}, name = #{name}, description = #{description} where id = #{id}")
    int update(Book book);

    @Delete("delete from ssm_db.tbl_book where id = #{id}")
    int delete(Integer id);

    @Select("select * from ssm_db.tbl_book where id = #{id}")
    Book getById(Integer id);

    @Select("select * from ssm_db.tbl_book")
    List<Book> getAll();

    @Select("select * from  ssm_db.tbl_book where name like '%${name}%'")
    public List<Book> getByName(String name);
}
